package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupCustomerTelephone;

/**
 * Denne klasse bruges til at hente al data i bs_customer_telephone og returnerer det
 * @author junjie
 */
public abstract class BackupCustomerTelephoneHandler {
    
    /**
     * Henter alle rækker i bs_customer_telephone og returnerer et BackupCustomerTelephone[] model
     * @return BackupCustomerTelephone[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
    public static BackupCustomerTelephone[] getCustomerTelephone() throws ClassNotFoundException, SQLException{
        BackupCustomerTelephone[] customerTelephoneArray = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_customer_telephone", "", "", "", "fk_customer", "number");
        customerTelephoneArray = new BackupCustomerTelephone[result.length];
        
        db.closeDB();
        
        for (int i = 0; i < result.length; i++) {
            
            customerTelephoneArray[i] = new BackupCustomerTelephone(Integer.parseInt(result[i][0]), result[i][1]);
        }
        return customerTelephoneArray;
        
    }
}
